home *** CD-ROM | disk | FTP | other *** search
- package asp.wizard;
-
- import asp.netobjects.nfx.util.ExceptionHandler;
- import asp.netobjects.nfx.util.ExternalError;
- import asp.netobjects.nfx.util.InternalError;
- import asp.util.ResourceUtil;
- import asp.wizard.util.UiUtil;
- import com.sun.java.swing.JDialog;
- import com.sun.java.swing.JFrame;
- import com.sun.java.swing.JOptionPane;
- import java.awt.Component;
- import java.awt.Container;
- import java.awt.Dialog;
- import java.awt.Dimension;
- import java.util.Hashtable;
-
- public class AspWizardExceptionHandler implements ExceptionHandler {
- public static final int INTERNAL_ERROR_MESSAGE = -2;
- private static Hashtable _msgTypeToTitle;
- private Container _parent;
- // $FF: synthetic field
- static Class class$asp$wizard$AspWizard;
-
- public AspWizardExceptionHandler(Container parent) {
- this._parent = parent;
- }
-
- public void handleException(Throwable t) {
- String title = "";
- String formatted = UiUtil.formatDialogText(t.getMessage());
- if (t instanceof ExternalError) {
- title = getTitle(0);
- }
-
- if (t instanceof InternalError) {
- title = getTitle(-2);
- }
-
- showMessageDialog(this._parent, formatted, title, 0);
- }
-
- private static String getTitle(int msgType) {
- Integer msgTypeInt = new Integer(msgType);
- String result = (String)_msgTypeToTitle.get(msgTypeInt);
- if (result == null) {
- result = "";
- }
-
- return result;
- }
-
- public static void showMessage(int msgType, String msg) {
- String formatted = UiUtil.formatDialogText(msg);
- showMessageDialog((Component)null, formatted, getTitle(msgType), msgType);
- }
-
- public static void showMessage(int msgType, String msg, Component parent) {
- String formatted = UiUtil.formatDialogText(msg);
- showMessageDialog(parent, formatted, getTitle(msgType), msgType);
- }
-
- private static void showMessageDialog(Component parent, String message, String title, int messageType) {
- JOptionPane pane = new JOptionPane(message, messageType, -1);
- JDialog dlg = pane.createDialog((Component)(parent == null ? new JFrame() : parent), title);
- Dimension size = ((Component)dlg).getSize();
- size.width += 5;
- ((Component)dlg).setSize(size);
- ((Dialog)dlg).show();
- }
-
- // $FF: synthetic method
- static Class class$(String class$) {
- try {
- return Class.forName(class$);
- } catch (ClassNotFoundException forName) {
- throw new NoClassDefFoundError(((Throwable)forName).getMessage());
- }
- }
-
- static {
- String resBase = "asp.wizard.res";
- Class ownerClass = class$asp$wizard$AspWizard != null ? class$asp$wizard$AspWizard : (class$asp$wizard$AspWizard = class$("asp.wizard.AspWizard"));
- _msgTypeToTitle = new Hashtable();
- _msgTypeToTitle.put(new Integer(-2), ResourceUtil.getResourceString(resBase, ownerClass, "exceptionhandler.title.internalerror"));
- _msgTypeToTitle.put(new Integer(0), ResourceUtil.getResourceString(resBase, ownerClass, "exceptionhandler.title.error"));
- _msgTypeToTitle.put(new Integer(1), ResourceUtil.getResourceString(resBase, ownerClass, "exceptionhandler.title.information"));
- _msgTypeToTitle.put(new Integer(2), ResourceUtil.getResourceString(resBase, ownerClass, "exceptionhandler.title.warning"));
- _msgTypeToTitle.put(new Integer(3), ResourceUtil.getResourceString(resBase, ownerClass, "exceptionhandler.title.question"));
- _msgTypeToTitle.put(new Integer(-1), ResourceUtil.getResourceString(resBase, ownerClass, "exceptionhandler.title.plainmessage"));
- }
- }
-